#!/usr/bin/env python
# -*- coding: utf-8 -*-
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: xrange.py
# Description: 
#    1. range 是全部產生完後，return一個 list 回來使用。
#    2. xrange 是一次產生一個值，並return一個值回來，所以xrange只適用於loop。
#    
#    所以在效能上，處理完一次的 loop 後，range 跟 xrange 是差不多的，
#    但是如果 loop 裡面有break 的機會，那麼，使用 xrange 是會比較省時的。
#    如果一定要跑完全部的 loop 的話，用range 應該是比較好的。
# Edit History: 
#   2011-10-13    File created.
#===============================================================================
for i in range(1, 10) :
    print i,
#>>> 1 2 3 4 5 6 7 8 9

for i in xrange(1, 10):
    if i == 5 :
        break
    print i,
#>>> 1 2 3 4
